import { RouteLocationNormalized } from "vue-router";

export default defineNuxtRouteMiddleware(
  (to: RouteLocationNormalized, from: RouteLocationNormalized) => {
    const { type, page } = to.params;
    const { keyword } = to.query;
    console.log(type, page, keyword);
    console.log(toString.call(+page));
    if (
      (type && !["column", "course"].includes(type as string)) ||
      isNaN(+page)
    ) {
      return abortNavigation("页面找不到");
    }
    if (keyword == "" || keyword == undefined) {
      return abortNavigation("搜索关键词不能为空");
    }
  }
);
